﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace NFinal.Sql.Like
{
    public class UTF8Key
    {
        private int times = 10;
        private int[] keys;
        private int[] keys1;
        private int[] keys2;
        private int[] keys3;
        private int[] keys4;
        private int[] keys5;
        private int[] keys6;

        public int Times {
            get
            {
                return times;
            }
        }

        public int[] Keys {
            get
            {
                return keys;
            }
        }

        public int[] Keys1 {
            get
            {
                return keys1;
            }
        }

        public int[] Keys2 {
            get
            {
                return keys2;
            }
        }
        public int[] Keys3
        {
            get {
                return keys3;
            }
        }
        public int[] Keys4
        {
            get {
                return keys4;
            }
        }

        public int[] Keys5
        {
            get {
                return keys5;
            }
        }

        public int[] Keys6
        {
            get {
                return keys6;
            }
        }
        private static int[] Bytes2Ints(byte[] bytes)
        {
            int[] ints = new int[bytes.Length >> 2];
            for (int i = 0; i < ints.Length; i++)
            {
                ints[i] = bytes[(i << 2)] | (bytes[(i << 2) + 1] << 8) | (bytes[(i << 2) + 2] << 16) | (bytes[(i << 2) + 3] << 24);
            }
            return ints;
        }
        public UTF8Key(byte[] keys)
        {
            this.keys =Bytes2Ints(keys);
            this.times = keys[0];
            this.keys1 = new int[times];
            this.keys2 = new int[times];
            this.keys3 = new int[times];
            this.keys4 = new int[times];
            this.keys5 = new int[times];
            this.keys6 = new int[times];
            Array.Copy(keys, 0 * times + 1, this.keys1, 0, times);
            Array.Copy(keys, 1 * times + 1, this.keys2, 0, times);
            Array.Copy(keys, 2 * times + 1, this.keys3, 0, times);
            Array.Copy(keys, 3 * times + 1, this.keys4, 0, times);
            Array.Copy(keys, 4 * times + 1, this.keys5, 0, times);
            Array.Copy(keys, 5 * times + 1, this.keys6, 0, times);
        }
    }
}
